package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.MesMatbom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.MesBuyDetailsMapper;
import com.ruoyi.system.domain.MesBuyDetails;
import com.ruoyi.system.service.IMesBuyDetailsService;

/**
 * 采购订单明细Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-06-17
 */
@Service
public class MesBuyDetailsServiceImpl implements IMesBuyDetailsService 
{
    @Autowired
    private MesBuyDetailsMapper mesBuyDetailsMapper;

    /**
     * 查询采购订单明细
     * 
     * @param id 采购订单明细主键
     * @return 采购订单明细
     */
    @Override
    public MesBuyDetails selectMesBuyDetailsById(Integer id)
    {
        return mesBuyDetailsMapper.selectMesBuyDetailsById(id);
    }

    /**
     * 查询采购订单明细列表
     * 
     * @param mesBuyDetails 采购订单明细
     * @return 采购订单明细
     */
    @Override
    public List<MesBuyDetails> selectMesBuyDetailsList(MesBuyDetails mesBuyDetails)
    {
        return mesBuyDetailsMapper.selectMesBuyDetailsList(mesBuyDetails);
    }

    /**
     * 新增采购订单明细
     * 
     * @param mesBuyDetails 采购订单明细
     * @return 结果
     */
    @Override
    public int insertMesBuyDetails(MesBuyDetails mesBuyDetails)
    {

        return mesBuyDetailsMapper.insertMesBuyDetails(mesBuyDetails);
//        List<MesBuyDetails> mtrs = mesBuyDetails.getMtrs();
//
//        for (MesBuyDetails mtr : mtrs) {
//            //1：处理数据
//            mtr.setMatId(mtr.getMatId());
//            mtr.setBuyOrdId(mtr.getBuyOrdId());
//            mtr.setNeedMatNum(mtr.getNeedMatNum());
//            //2.sql插入
//            mesBuyDetailsMapper.insertMesBuyDetails(mtr);
//        }
//        return 1;

    }

    /**
     * 修改采购订单明细
     * 
     * @param mesBuyDetails 采购订单明细
     * @return 结果
     */
    @Override
    public int updateMesBuyDetails(MesBuyDetails mesBuyDetails)
    {
        return mesBuyDetailsMapper.updateMesBuyDetails(mesBuyDetails);
    }

    /**
     * 批量删除采购订单明细
     * 
     * @param ids 需要删除的采购订单明细主键
     * @return 结果
     */
    @Override
    public int deleteMesBuyDetailsByIds(Integer[] ids)
    {
        return mesBuyDetailsMapper.deleteMesBuyDetailsByIds(ids);
    }

    /**
     * 删除采购订单明细信息
     * 
     * @param id 采购订单明细主键
     * @return 结果
     */
    @Override
    public int deleteMesBuyDetailsById(Integer id)
    {
        return mesBuyDetailsMapper.deleteMesBuyDetailsById(id);
    }

    @Override
    public List<String> selectOrdMats(String buyOrdId){
        return mesBuyDetailsMapper.selectOrdMats(buyOrdId);
    }
}
